using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Squadron
{
    class HUD : DrawableGameComponent
    {
        #region Member variables

        private ContentManager _contentManager;
        private SpriteBatch _spriteBatch;
        private SpriteFont _font;

        private int _life = 0;
        private int _ammo = 0;

        #endregion

        /// <summary>
        /// Creates a new FPS counter component.
        /// </summary>
        /// <param name="game">The host application.</param>
        public HUD(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            _contentManager = new ContentManager(game.Services, "Content");
        }

        /// <summary>
        /// Creates a SpriteBatch object and loads the font.
        /// </summary>
        protected override void LoadContent()
        {            
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _font = _contentManager.Load<SpriteFont>("Fonts/FPS");

            base.LoadContent();
        }

        /// <summary>
        /// Draws the current FPS on screen.
        /// </summary>
        /// <param name="gameTime">Timing information.</param>
        public override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin();
            _spriteBatch.DrawString(_font, " Life: " + _life.ToString(), new Vector2(40.0f, 100.0f +
                _font.MeasureString(_life.ToString()).Y), Color.White);
            _spriteBatch.End();
            GraphicsDevice.RenderState.DepthBufferEnable = true;
            base.Draw(gameTime);
        }

        public int Life
        {
            set { _life = value; }
        }
    }
}
